import { reqGetSearch } from "@/api";

const state ={
    searchList:{}
};
const mutations={
    GETSEARCHLIST(state,value){
        state.searchList=value
    }
};
const actions = {
    async getSearchList(context,value={}){
        let result=await reqGetSearch(value);
        if(result.code===200){
            context.commit('GETSEARCHLIST',result.data)
        }
    }
};
const getters={
    goodsList(state){
        //初始为空对象，防止属性undefined
        return state.searchList.goodsList||[];
    },
    trademarkList(state){
        return state.searchList.trademarkList||[];
    },
    attrsList(state){
        return state.searchList.attrsList||[];
    }
};

export default {
    namespaced: true,
    state,
    actions,
    mutations,
    getters
}